#define _CRT_SECURE_NO_WARNINGS 1
#pragma warning(disable:6031)
#include<stdio.h>
int BinarySearch(int* p, int n, int x)
{
	int right = n-1;
	int left = 0;
	int mid = 0;
	while (left <= right)
	{
		mid = (left + right) / 2;
		if (p[mid] < x)
		{
			left = mid + 1;
		}
		else if (p[mid] > x)
		{
			right = mid - 1;
		}
		else
		{
			return mid;
		}
	}
	return 0;
}
int main()
{
	int arr[] = { 1,2,3,4,5,6,7,8,9,10};
	int tmp = BinarySearch(arr, 10, 7);
	printf("%d ", tmp);
	return 0;
}